home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbench / vbench.frm < prev    next >
Text File  |  1994-07-13  |  14KB  |  472 lines

  1. VERSION 2.00
  2. Begin Form Vbench 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "VBench"
  5.    ClientHeight    =   3228
  6.    ClientLeft      =   1584
  7.    ClientTop       =   660
  8.    ClientWidth     =   5172
  9.    Height          =   3648
  10.    Left            =   1536
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   3228
  13.    ScaleWidth      =   5172
  14.    Top             =   288
  15.    Width           =   5268
  16.    Begin TextBox Text1 
  17.       Height          =   372
  18.       Index           =   4
  19.       Left            =   2520
  20.       TabIndex        =   8
  21.       Text            =   "Text1"
  22.       Top             =   2160
  23.       Width           =   2412
  24.    End
  25.    Begin TextBox Text1 
  26.       Height          =   372
  27.       Index           =   3
  28.       Left            =   2520
  29.       TabIndex        =   7
  30.       Text            =   "Text1"
  31.       Top             =   1680
  32.       Width           =   2412
  33.    End
  34.    Begin TextBox Text1 
  35.       Height          =   372
  36.       Index           =   2
  37.       Left            =   2520
  38.       TabIndex        =   6
  39.       Text            =   "Text1"
  40.       Top             =   1200
  41.       Width           =   2412
  42.    End
  43.    Begin TextBox Text1 
  44.       Height          =   372
  45.       Index           =   1
  46.       Left            =   2520
  47.       TabIndex        =   5
  48.       Text            =   "Text1"
  49.       Top             =   720
  50.       Width           =   2412
  51.    End
  52.    Begin TextBox Text1 
  53.       Height          =   372
  54.       Index           =   0
  55.       Left            =   2520
  56.       TabIndex        =   4
  57.       Text            =   "Text1"
  58.       Top             =   240
  59.       Width           =   2412
  60.    End
  61.    Begin CommandButton Command1 
  62.       Caption         =   "E&xit"
  63.       Height          =   372
  64.       Index           =   3
  65.       Left            =   3840
  66.       TabIndex        =   3
  67.       Top             =   2760
  68.       Width           =   1092
  69.    End
  70.    Begin CommandButton Command1 
  71.       Caption         =   "&Populate"
  72.       Height          =   372
  73.       Index           =   2
  74.       Left            =   2640
  75.       TabIndex        =   2
  76.       Top             =   2760
  77.       Width           =   1092
  78.    End
  79.    Begin CommandButton Command1 
  80.       Caption         =   "&Select"
  81.       Height          =   372
  82.       Index           =   1
  83.       Left            =   1440
  84.       TabIndex        =   1
  85.       Top             =   2760
  86.       Width           =   1092
  87.    End
  88.    Begin CommandButton Command1 
  89.       Caption         =   "&Update"
  90.       Height          =   372
  91.       Index           =   0
  92.       Left            =   240
  93.       TabIndex        =   0
  94.       Top             =   2760
  95.       Width           =   1092
  96.    End
  97.    Begin Label Label1 
  98.       BackColor       =   &H00C0C0C0&
  99.       Caption         =   "Parameter QueryDef"
  100.       ForeColor       =   &H00FF0000&
  101.       Height          =   252
  102.       Index           =   4
  103.       Left            =   240
  104.       TabIndex        =   13
  105.       Top             =   2160
  106.       Width           =   2412
  107.    End
  108.    Begin Label Label1 
  109.       BackColor       =   &H00C0C0C0&
  110.       Caption         =   "Static QueryDef"
  111.       ForeColor       =   &H00FF0000&
  112.       Height          =   252
  113.       Index           =   3
  114.       Left            =   240
  115.       TabIndex        =   12
  116.       Top             =   1680
  117.       Width           =   2412
  118.    End
  119.    Begin Label Label1 
  120.       BackColor       =   &H00C0C0C0&
  121.       Caption         =   "Inline VB SQL"
  122.       ForeColor       =   &H00FF0000&
  123.       Height          =   252
  124.       Index           =   2
  125.       Left            =   240
  126.       TabIndex        =   11
  127.       Top             =   1200
  128.       Width           =   2412
  129.    End
  130.    Begin Label Label1 
  131.       BackColor       =   &H00C0C0C0&
  132.       Caption         =   "Dynaset FindFirst"
  133.       ForeColor       =   &H00FF0000&
  134.       Height          =   252
  135.       Index           =   1
  136.       Left            =   240
  137.       TabIndex        =   10
  138.       Top             =   720
  139.       Width           =   2412
  140.    End
  141.    Begin Label Label1 
  142.       BackColor       =   &H00C0C0C0&
  143.       Caption         =   "ISAM Table Seek"
  144.       ForeColor       =   &H00FF0000&
  145.       Height          =   252
  146.       Index           =   0
  147.       Left            =   240
  148.       TabIndex        =   9
  149.       Top             =   240
  150.       Width           =   2412
  151.    End
  152. End
  153. 'Declarations
  154.  
  155. Option Explicit
  156. Dim db As database
  157. Dim tbl As Table
  158. Dim dyna As dynaset
  159. Dim qd As querydef
  160. Dim foo As Integer
  161. Declare Function GetTickCount Lib "User" () As Long
  162.  
  163.  
  164. Sub CloseDb ()
  165. On Error Resume Next
  166.     dyna.Close
  167.     tbl.Close
  168.     qd.Close
  169.     db.Close
  170.     DoEvents
  171. End Sub
  172.  
  173. Sub Command1_Click (Index As Integer)
  174. Dim TimeCount As Long, TimeStart As Long
  175. Dim foobar As Integer, foo As Integer
  176. ReDim cost(5) As Double
  177.  
  178. TimeCount = 0
  179. 'Set the hourglass
  180. Screen.MousePointer = 11
  181.  
  182. Select Case Index
  183.  
  184. 'Update Operations ======================================
  185. 'The objective here is to examine 1000 out of 10,000 records,
  186. 'and modify those that match a given criteria - about 200 writes
  187. Case 0
  188.     Me.Caption = "VBench: Update Operation Benchmarks"
  189.     FileCopy "C:\vb\IoTest.Mdb", "C:\vb\IoTest.Bak"
  190.     'Seeks and indexed sequential updates ---------------
  191.     'Open the database logicals
  192.     OpenDb
  193.     'Start the clock
  194.     TimeStart = GetTickCount()
  195.     'Use transactions for speed
  196.     BeginTrans
  197.     'Jump to first ID using a fast seek
  198.     tbl.Seek ">=", 5000
  199.     'Continue searching till eof or break
  200.     Do Until tbl.EOF
  201.     'Test if reached top of range
  202.     If tbl!id < 6000 Then
  203.         'Test if record meets change criteria
  204.         If tbl!cost > 30 And tbl!cost < 40 Then
  205.         tbl.Edit
  206.         tbl!cost = tbl!cost * .9
  207.         tbl.Update
  208.         End If
  209.     Else
  210.         'Exit if past top of range
  211.         Exit Do
  212.     End If
  213.     'Get the next record
  214.     tbl.MoveNext
  215.     Loop
  216.     CommitTrans
  217.     'Stop the clock and report
  218.     TimeCount = GetTickCount() - TimeStart
  219.     Text1(0) = Format$(TimeCount / 1000, "##0.00")
  220.     CloseDb
  221.     'Dynaset FindFirst ---------------------------------------
  222.     'Start each iteration with same file
  223.     FileCopy "C:\vb\IoTest.bak", "C:\vb\IoTest.mdb"
  224.     'Open the data logicals
  225.     OpenDb
  226.     'Start The Clock
  227.     TimeStart = GetTickCount()
  228.     'Use transactions for speed
  229.     BeginTrans
  230.     'Jump to first record
  231.     dyna.FindFirst "Id >= 5000"
  232.     'Continue searching till eof or break
  233.     Do Until dyna.EOF
  234.     'Test if reached top of range
  235.     If dyna!id < 6000 Then
  236.         'Test if record meets change criteria
  237.         If dyna!cost > 30 And dyna!cost < 40 Then
  238.         dyna.Edit
  239.         dyna!cost = dyna!cost * .9
  240.         dyna.Update
  241.         End If
  242.     Else
  243.         'Exit loop if past top of range
  244.         Exit Do
  245.     End If
  246.     'Get the next record
  247.     dyna.MoveNext
  248.     Loop
  249.     CommitTrans
  250.     'Stop the clock and report
  251.     TimeCount = GetTickCount() - TimeStart
  252.     Text1(1) = Format$(TimeCount / 1000, "##0.00")
  253.     CloseDb
  254.     'Test SQL processing with inline VB code ----------
  255.     'Start each iteration with same file
  256.     FileCopy "C:\vb\IoTest.bak", "C:\vb\IoTest.mdb"
  257.     'Open the database logicals
  258.     OpenDb
  259.     'Start The Clock
  260.     TimeStart = GetTickCount()
  261.     'Execute the statement on databse DB
  262.     db.Execute "Update testtable Set Cost = Cost *.9 where cost > 30 and cost < 40 and id >= 5000 and id < 6000 and id/2 = id\2"
  263.     'Stop the clock and report
  264.     TimeCount = GetTickCount() - TimeStart
  265.     Text1(2) = Format$(TimeCount / 1000, "##0.00")
  266.     CloseDb
  267.     'Test SQL processing with Stored QueryDef -------
  268.     'Start each iteration with same file
  269.     FileCopy "C:\vb\IoTest.bak", "C:\vb\IoTest.mdb"
  270.     'Open the database logicals
  271.     OpenDb
  272.     'Store the procedure before starting the clock
  273.     Set qd = db.CreateQueryDef("TestQd", "Update testtable Set Cost = Cost *.9 where cost > 30 and Cost < 40 and id >= 5000 and id < 6000")
  274.     qd.Close
  275.     'Start The Clock
  276.     TimeStart = GetTickCount()
  277.     'Use Transactions for speed
  278.     BeginTrans
  279.     'Execute the querydef on database DB
  280.     db.Execute "TestQd"
  281.     CommitTrans